/*** vender ***/
package gui;

import comm.Communication;
import comm.Products;
import comm.Sales;
import db.DataBase;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.filechooser.FileFilter;
import javax.swing.table.TableModel;
import main.Contact;
import main.User;
import org.jfree.data.xy.XYSeries;
import org.jfree.ui.ExtensionFileFilter;
import org.jvnet.substance.SubstanceLegacyDefaultLookAndFeel;
import org.jvnet.substance.skin.SubstanceAutumnLookAndFeel;
import org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel;
import org.jvnet.substance.skin.SubstanceBusinessBlueSteelLookAndFeel;
import org.jvnet.substance.skin.SubstanceBusinessLookAndFeel;
import org.jvnet.substance.skin.SubstanceChallengerDeepLookAndFeel;
import org.jvnet.substance.skin.SubstanceCremeCoffeeLookAndFeel;
import org.jvnet.substance.skin.SubstanceCremeLookAndFeel;
import org.jvnet.substance.skin.SubstanceEmeraldDuskLookAndFeel;
import org.jvnet.substance.skin.SubstanceMagmaLookAndFeel;
import org.jvnet.substance.skin.SubstanceMistAquaLookAndFeel;
import org.jvnet.substance.skin.SubstanceMistSilverLookAndFeel;
import org.jvnet.substance.skin.SubstanceModerateLookAndFeel;
import org.jvnet.substance.skin.SubstanceNebulaBrickWallLookAndFeel;
import org.jvnet.substance.skin.SubstanceNebulaLookAndFeel;
import org.jvnet.substance.skin.SubstanceOfficeBlue2007LookAndFeel;
import org.jvnet.substance.skin.SubstanceOfficeSilver2007LookAndFeel;
import org.jvnet.substance.skin.SubstanceRavenGraphiteGlassLookAndFeel;
import org.jvnet.substance.skin.SubstanceRavenGraphiteLookAndFeel;
import org.jvnet.substance.skin.SubstanceRavenLookAndFeel;
import org.jvnet.substance.skin.SubstanceSaharaLookAndFeel;
import util.Calendar;
import util.Chart;
import util.Server;

/**
 *
 * @author Hugo
 */
public class mainFrame extends javax.swing.JFrame {

  private static final long serialVersionUID = -2534463334456223227L;

  /** Creates new form mainFrame */
  public mainFrame() {
    // initializes the components of gui
    initComponents();
    // makes invisible all extra panels
    calendarPanel.setVisible(false);
    chartsPanel.setVisible(false);
    dbPanel.setVisible(false);
    helpPanel.setVisible(false);
    phonesPanel.setVisible(false);
    prodPanel.setVisible(false);
    salesPanel.setVisible(false);
    settingsPanel.setVisible(false);
    loginPanel.setVisible(false);
    saleDialog.setVisible(false);
    aboutDialog.setVisible(false);
    // set the current panel
    currentPanel = defaultPanel;
  }

  /**
   * Shows a panel, and hides the old one
   * @param p
   */
  private void showPanel(JPanel p) {
    // if p is null then the current panel was closed
    if (p == null) {
      p = defaultPanel;
      toolbarbuttonGroup.clearSelection();
    }
    // hide it
    currentPanel.setVisible(false);
    // show it
    p.setVisible(true);
    // mark the new
    currentPanel = p;
  }

  /**--- Products Table ---**/
  private void createProdTable() {
    prodTable.setAutoCreateRowSorter(true);
    prodTable.setModel(new javax.swing.table.DefaultTableModel(Products.getData(), Products.getHeaders()));
    prodTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

      public void valueChanged(ListSelectionEvent e) {
        // check if it is the first event
        if (!e.getValueIsAdjusting()) {
          int first = e.getFirstIndex();
          int last = e.getLastIndex();
          int row = first == currentProdRow ? last : first;
          if (row < 0) {
            return;
          }
          currentProdRow = row;
          String[] d = Products.getData(row);
          saleDialogID.setText("ID: " + d[0]);
          saleDialogName.setText("Nome: " + d[1]);
          saleDialogType.setText("Tipo: " + d[2]);
          saleDialogPrice.setText("Preço: " + d[3]);
          saleDialogReqTotal.setText("/ " + d[4]);
          saleDialogAmountTotal.setText("/ " + d[5]);
          saleDialog.pack();
          saleDialog.setLocationRelativeTo(null);
          saleDialog.setVisible(true);
        }
      }
    });
  }

  private void refreshProdTable() {
    prodTable.setModel(new javax.swing.table.DefaultTableModel(Products.getData(), Products.getHeaders()));
    prodTable.clearSelection();
  }

  /**--- Sales Table ---**/
  private void createSalesTable() {
    salesTable.setAutoCreateRowSorter(true);
    salesTable.setModel(new javax.swing.table.DefaultTableModel(Sales.getData(), Sales.getHeaders()));
  }

  private void refreshSalesTable() {
    salesTable.setModel(new javax.swing.table.DefaultTableModel(Sales.getData(), Sales.getHeaders()));
    salesTable.clearSelection();
  }

  /**-- Phones Table --**/
  private void createPhonesTable() {
    /* provisorio - deve estar na base de dados */
    User.addContact("Hugo", "1111-1111", "hugo@mail.com");
    User.addContact("Eduardo", "2222-2222", "eduardo@mail.com");
    User.addContact("Parra", "3333-3333", "parra@mail.com");

    User.editContact(new Contact("Hugo", "1111-1111", "hugo@mail.com"), "Hugo2", null, null);


    phonesTable.setAutoCreateRowSorter(true);
    phonesTable.setModel(new javax.swing.table.DefaultTableModel(User.getContactsData(), User.getContactsHeaders()));

  }

  private void refreshPhonesTable() {
    phonesTable.setAutoCreateRowSorter(true);
    phonesTable.setModel(new javax.swing.table.DefaultTableModel(User.getContactsData(), User.getContactsHeaders()));
  }

  private void savePhoneTable() {
    TableModel model = phonesTable.getModel();
    int rowCount = model.getRowCount();
    int columnCount = model.getColumnCount();
    String[][] cData = new String[rowCount][columnCount];
    for (int i = 0; i < rowCount; i++) {
      for (int j = 0; j < columnCount; j++) {
        cData[i][j] = (String) model.getValueAt(i, j);
      }
    }
    User.saveContacts(cData);
  }

  /**-- Calendar --**/
  private void showCalendar(int target) {

    String[][] data;
    switch (target) {
      case Calendar.PREVIOUS_MONTH:
        data = Calendar.getCalendarPreviousMonth();
        break;
      case Calendar.TODAY:
        data = Calendar.getTodayCalendar();
        break;
      case Calendar.NEXT_MONTH:
        data = Calendar.getCalendarNextMonth();
        break;
      default:
        data = new String[6][7];
        break;
    }

    calendarTable.setModel(new javax.swing.table.DefaultTableModel(data, Calendar.days));
    calendarMonthAndYearLabel.setText(Calendar.getMonthAndYear());
    int[] pos = Calendar.getTodayPosition();
    if (pos[0] == -1 || pos[1] == -1) {
      return;
    }
    calendarTable.changeSelection(pos[0], pos[1], false, false);

  }

  private void showCalendar(int year, int month) {

    calendarTable.setModel(new javax.swing.table.DefaultTableModel(Calendar.getCalendar(year, month), Calendar.days));
    calendarMonthAndYearLabel.setText(Calendar.getMonthAndYear());
    int[] pos = Calendar.getTodayPosition();
    if (pos[0] == -1 || pos[1] == -1) {
      return;
    }
    calendarTable.changeSelection(pos[0], pos[1], false, false);
  }

  /** This method is called from within the constructor to
   * initialize the form.
   * WARNING: Do NOT modify this code. The content of this method is
   * always regenerated by the Form Editor.
   */
  @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {

    toolbarbuttonGroup = new javax.swing.ButtonGroup();
    saleDialog = new javax.swing.JDialog();
    saleDialogID = new javax.swing.JLabel();
    saleDialogName = new javax.swing.JLabel();
    saleDialogType = new javax.swing.JLabel();
    saleDialogPrice = new javax.swing.JLabel();
    saleDialogAmount = new javax.swing.JLabel();
    saleDialogAmountField = new javax.swing.JTextField();
    saleDialogAmountTotal = new javax.swing.JLabel();
    saleDialogCancelButton = new javax.swing.JButton();
    saleDialogOKButton = new javax.swing.JButton();
    saleDialogReqButton = new javax.swing.JButton();
    saleDialogAmount1 = new javax.swing.JLabel();
    saleDialogReqField = new javax.swing.JTextField();
    saleDialogReqTotal = new javax.swing.JLabel();
    saleDialogDevButton = new javax.swing.JButton();
    aboutDialog = new javax.swing.JDialog();
    aboutDialogLabel = new javax.swing.JLabel();
    chartDialog = new javax.swing.JDialog();
    chartDialogLabel = new javax.swing.JLabel();
    chartCloseButton = new javax.swing.JButton();
    chartSaveButton = new javax.swing.JButton();
    chartVerifyButton = new javax.swing.JButton();
    mainPanel = new javax.swing.JPanel();
    toolBar = new javax.swing.JToolBar();
    prodButton = new javax.swing.JToggleButton();
    salesButton = new javax.swing.JToggleButton();
    chartsButton = new javax.swing.JToggleButton();
    dbButton = new javax.swing.JToggleButton();
    phoneButton = new javax.swing.JToggleButton();
    calendarButton = new javax.swing.JToggleButton();
    settingsButton = new javax.swing.JToggleButton();
    helpButton = new javax.swing.JToggleButton();
    contentPanel = new javax.swing.JPanel();
    loginPanel = new javax.swing.JPanel();
    prodCloseButton1 = new javax.swing.JButton();
    loginLabel = new javax.swing.JLabel();
    loginUserLabel = new javax.swing.JLabel();
    loginPassLabel = new javax.swing.JLabel();
    loginUserField = new javax.swing.JTextField();
    loginPassField = new javax.swing.JPasswordField();
    loginClearButton = new javax.swing.JButton();
    loginCancelButton = new javax.swing.JButton();
    loginOKButton = new javax.swing.JButton();
    helpPanel = new javax.swing.JPanel();
    helpCloseButton = new javax.swing.JButton();
    jLabel5 = new javax.swing.JLabel();
    settingsPanel = new javax.swing.JPanel();
    settingsCloseButton = new javax.swing.JButton();
    settingsLabel = new javax.swing.JLabel();
    settingsConLabel = new javax.swing.JPanel();
    settingsServerLabel = new javax.swing.JLabel();
    settingsServerCombobox = new javax.swing.JComboBox();
    settingsServerConnectButton = new javax.swing.JButton();
    settingsServerListRefreshButton = new javax.swing.JButton();
    settingsServerEditButton = new javax.swing.JButton();
    settingsServerTextField = new javax.swing.JTextField();
    calendarPanel = new javax.swing.JPanel();
    calendarCloseButton = new javax.swing.JButton();
    calendarLabel = new javax.swing.JLabel();
    calendarScrollPane = new javax.swing.JScrollPane();
    calendarTable = new javax.swing.JTable();
    calendarNextButton = new javax.swing.JButton();
    calendarPreviousButton = new javax.swing.JButton();
    calendarMonthAndYearLabel = new javax.swing.JLabel();
    calendarTodayButton = new javax.swing.JButton();
    calendarGoButton = new javax.swing.JButton();
    calendarMonthComboBox = new javax.swing.JComboBox();
    calendarYearTextfield = new javax.swing.JTextField();
    phonesPanel = new javax.swing.JPanel();
    phonesCloseButton = new javax.swing.JButton();
    phonesRefreshButton = new javax.swing.JButton();
    phonesSaveButton = new javax.swing.JButton();
    phonesLabel = new javax.swing.JLabel();
    phonesTableScrollPane = new javax.swing.JScrollPane();
    phonesTable = new javax.swing.JTable();
    dbPanel = new javax.swing.JPanel();
    dbCloseButton = new javax.swing.JButton();
    dbLabel = new javax.swing.JLabel();
    dbSynchButton = new javax.swing.JButton();
    chartsPanel = new javax.swing.JPanel();
    chartsCloseButton = new javax.swing.JButton();
    chartsLabel = new javax.swing.JLabel();
    chartsTabbedPane = new javax.swing.JTabbedPane();
    chartsSalesPanel = new javax.swing.JPanel();
    chartSalesLabel = new javax.swing.JLabel();
    chartsRequestsPanel = new javax.swing.JPanel();
    chartRequestsLabel = new javax.swing.JLabel();
    salesPanel = new javax.swing.JPanel();
    salesCloseButton = new javax.swing.JButton();
    salesLabel = new javax.swing.JLabel();
    salesTableScrollPane = new javax.swing.JScrollPane();
    salesTable = new javax.swing.JTable();
    salesRefreshButton = new javax.swing.JButton();
    salesCreateChartButton = new javax.swing.JButton();
    salesSelectAllButton = new javax.swing.JButton();
    prodPanel = new javax.swing.JPanel();
    prodLabel = new javax.swing.JLabel();
    prodCloseButton = new javax.swing.JButton();
    prodTableScrollPane = new javax.swing.JScrollPane();
    prodTable = new javax.swing.JTable();
    prodRefreshButton = new javax.swing.JButton();
    prodDevButton = new javax.swing.JButton();
    defaultPanel = new javax.swing.JPanel();
    jLabel2 = new javax.swing.JLabel();
    jScrollPane1 = new javax.swing.JScrollPane();
    jTextArea1 = new javax.swing.JTextArea();
    jSeparator1 = new javax.swing.JToolBar.Separator();
    loginToolbar = new javax.swing.JToolBar();
    loginButton = new javax.swing.JButton();
    menuBar = new javax.swing.JMenuBar();
    jMenu1 = new javax.swing.JMenu();
    jMenuItem1 = new javax.swing.JMenuItem();
    jMenu3 = new javax.swing.JMenu();
    jMenu4 = new javax.swing.JMenu();
    jMenuItem4 = new javax.swing.JMenuItem();
    jMenu5 = new javax.swing.JMenu();
    jMenuItem13 = new javax.swing.JMenuItem();
    jMenuItem11 = new javax.swing.JMenuItem();
    jMenuItem12 = new javax.swing.JMenuItem();
    jMenuItem10 = new javax.swing.JMenuItem();
    jMenu6 = new javax.swing.JMenu();
    jMenuItem9 = new javax.swing.JMenuItem();
    jMenuItem3 = new javax.swing.JMenuItem();
    jMenuItem8 = new javax.swing.JMenuItem();
    jMenuItem7 = new javax.swing.JMenuItem();
    jMenuItem6 = new javax.swing.JMenuItem();
    jMenu7 = new javax.swing.JMenu();
    jMenuItem5 = new javax.swing.JMenuItem();
    jMenuItem17 = new javax.swing.JMenuItem();
    jMenuItem16 = new javax.swing.JMenuItem();
    jMenu8 = new javax.swing.JMenu();
    jMenuItem18 = new javax.swing.JMenuItem();
    jMenuItem15 = new javax.swing.JMenuItem();
    jMenu9 = new javax.swing.JMenu();
    jMenuItem14 = new javax.swing.JMenuItem();
    jMenuItem19 = new javax.swing.JMenuItem();
    jMenu10 = new javax.swing.JMenu();
    jMenuItem22 = new javax.swing.JMenuItem();
    jMenuItem2 = new javax.swing.JMenuItem();
    jMenuItem21 = new javax.swing.JMenuItem();
    jMenuItem23 = new javax.swing.JMenuItem();
    jMenu11 = new javax.swing.JMenu();
    jMenuItem20 = new javax.swing.JMenuItem();

    saleDialog.setTitle("Venda");
    saleDialog.setModal(true);

    saleDialogID.setText("ID:");

    saleDialogName.setText("Nome:");

    saleDialogType.setText("Tipo:");

    saleDialogPrice.setText("Preço:");

    saleDialogAmount.setText("Quantidade:");

    saleDialogAmountTotal.setText("/ 5000");

    saleDialogCancelButton.setText("Cancelar");
    saleDialogCancelButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        saleDialogCancelButtonActionPerformed(evt);
      }
    });

    saleDialogOKButton.setText("Vender");
    saleDialogOKButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        saleDialogOKButtonActionPerformed(evt);
      }
    });

    saleDialogReqButton.setText("Reservar");
    saleDialogReqButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        saleDialogReqButtonActionPerformed(evt);
      }
    });

    saleDialogAmount1.setText("Quantidade:");

    saleDialogReqTotal.setText("/ 5000");

    saleDialogDevButton.setText("Devolver produto ");
    saleDialogDevButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        saleDialogDevButtonActionPerformed(evt);
      }
    });

    javax.swing.GroupLayout saleDialogLayout = new javax.swing.GroupLayout(saleDialog.getContentPane());
    saleDialog.getContentPane().setLayout(saleDialogLayout);
    saleDialogLayout.setHorizontalGroup(
      saleDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(saleDialogLayout.createSequentialGroup()
        .addContainerGap()
        .addGroup(saleDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addGroup(saleDialogLayout.createSequentialGroup()
            .addGroup(saleDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addComponent(saleDialogName)
              .addComponent(saleDialogID)
              .addComponent(saleDialogType)
              .addComponent(saleDialogPrice)
              .addGroup(saleDialogLayout.createSequentialGroup()
                .addComponent(saleDialogAmount)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(saleDialogAmountField, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(saleDialogAmountTotal)))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 16, Short.MAX_VALUE)
            .addComponent(saleDialogOKButton))
          .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, saleDialogLayout.createSequentialGroup()
            .addComponent(saleDialogAmount1)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(saleDialogReqField, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
            .addComponent(saleDialogReqTotal)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 6, Short.MAX_VALUE)
            .addComponent(saleDialogReqButton))
          .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, saleDialogLayout.createSequentialGroup()
            .addComponent(saleDialogDevButton)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
            .addComponent(saleDialogCancelButton)))
        .addContainerGap())
    );
    saleDialogLayout.setVerticalGroup(
      saleDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(saleDialogLayout.createSequentialGroup()
        .addContainerGap()
        .addComponent(saleDialogID)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(saleDialogName)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(saleDialogType)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(saleDialogPrice)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(saleDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(saleDialogAmount)
          .addComponent(saleDialogAmountTotal)
          .addComponent(saleDialogAmountField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
          .addComponent(saleDialogOKButton))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
        .addGroup(saleDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(saleDialogReqButton)
          .addComponent(saleDialogAmount1)
          .addComponent(saleDialogReqTotal)
          .addComponent(saleDialogReqField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
        .addGroup(saleDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(saleDialogCancelButton)
          .addComponent(saleDialogDevButton))
        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );

    aboutDialog.setTitle("SMS - sobre");
    aboutDialog.setLocationByPlatform(true);
    aboutDialog.setModal(true);

    aboutDialogLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/about_box.png"))); // NOI18N
    aboutDialogLabel.addMouseListener(new java.awt.event.MouseAdapter() {
      public void mouseClicked(java.awt.event.MouseEvent evt) {
        aboutDialogLabelMouseClicked(evt);
      }
    });

    javax.swing.GroupLayout aboutDialogLayout = new javax.swing.GroupLayout(aboutDialog.getContentPane());
    aboutDialog.getContentPane().setLayout(aboutDialogLayout);
    aboutDialogLayout.setHorizontalGroup(
      aboutDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addComponent(aboutDialogLabel)
    );
    aboutDialogLayout.setVerticalGroup(
      aboutDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addComponent(aboutDialogLabel)
    );

    chartDialog.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    chartDialog.setTitle("SMS - Gráficos");
    chartDialog.setIconImage(null);
    chartDialog.setLocationByPlatform(true);
    chartDialog.setModal(true);
    chartDialog.addMouseListener(new java.awt.event.MouseAdapter() {
      public void mouseClicked(java.awt.event.MouseEvent evt) {
        chartDialogMouseClicked(evt);
      }
    });

    chartDialogLabel.setMaximumSize(new java.awt.Dimension(600, 400));
    chartDialogLabel.setPreferredSize(new java.awt.Dimension(600, 400));

    chartCloseButton.setText("Fechar");
    chartCloseButton.setFocusPainted(false);
    chartCloseButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        chartCloseButtonActionPerformed(evt);
      }
    });

    chartSaveButton.setText("Salvar");
    chartSaveButton.setFocusPainted(false);
    chartSaveButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        chartSaveButtonActionPerformed(evt);
      }
    });

    chartVerifyButton.setText("Verificar dados");
    chartVerifyButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        chartVerifyButtonActionPerformed(evt);
      }
    });

    javax.swing.GroupLayout chartDialogLayout = new javax.swing.GroupLayout(chartDialog.getContentPane());
    chartDialog.getContentPane().setLayout(chartDialogLayout);
    chartDialogLayout.setHorizontalGroup(
      chartDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addComponent(chartDialogLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 459, Short.MAX_VALUE)
      .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, chartDialogLayout.createSequentialGroup()
        .addContainerGap()
        .addComponent(chartVerifyButton)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 199, Short.MAX_VALUE)
        .addComponent(chartSaveButton)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
        .addComponent(chartCloseButton)
        .addContainerGap())
    );
    chartDialogLayout.setVerticalGroup(
      chartDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(chartDialogLayout.createSequentialGroup()
        .addComponent(chartDialogLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 308, Short.MAX_VALUE)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(chartDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(chartCloseButton)
          .addComponent(chartSaveButton)
          .addComponent(chartVerifyButton))
        .addContainerGap())
    );

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("SMS - Sales Management System");

    toolBar.setFloatable(false);
    toolBar.setRollover(true);

    toolbarbuttonGroup.add(prodButton);
    prodButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/prod.png"))); // NOI18N
    prodButton.setText("Produtos");
    prodButton.setFocusable(false);
    prodButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    prodButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    prodButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        prodButtonActionPerformed(evt);
      }
    });
    toolBar.add(prodButton);

    toolbarbuttonGroup.add(salesButton);
    salesButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/sales.png"))); // NOI18N
    salesButton.setText("Vendas");
    salesButton.setFocusable(false);
    salesButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    salesButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    salesButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        salesButtonActionPerformed(evt);
      }
    });
    toolBar.add(salesButton);

    toolbarbuttonGroup.add(chartsButton);
    chartsButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/charts.png"))); // NOI18N
    chartsButton.setText("Gráficos");
    chartsButton.setFocusable(false);
    chartsButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    chartsButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    chartsButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        chartsButtonActionPerformed(evt);
      }
    });
    toolBar.add(chartsButton);

    toolbarbuttonGroup.add(dbButton);
    dbButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/database.png"))); // NOI18N
    dbButton.setText("Banco de Dados");
    dbButton.setFocusable(false);
    dbButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    dbButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    dbButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        dbButtonActionPerformed(evt);
      }
    });
    toolBar.add(dbButton);

    toolbarbuttonGroup.add(phoneButton);
    phoneButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/phonebook.png"))); // NOI18N
    phoneButton.setText("Telefones");
    phoneButton.setFocusable(false);
    phoneButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    phoneButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    phoneButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        phoneButtonActionPerformed(evt);
      }
    });
    toolBar.add(phoneButton);

    toolbarbuttonGroup.add(calendarButton);
    calendarButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/calendar.png"))); // NOI18N
    calendarButton.setText("Calendário");
    calendarButton.setFocusable(false);
    calendarButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    calendarButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    calendarButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        calendarButtonActionPerformed(evt);
      }
    });
    toolBar.add(calendarButton);

    toolbarbuttonGroup.add(settingsButton);
    settingsButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/settings.png"))); // NOI18N
    settingsButton.setText("Configurações");
    settingsButton.setFocusable(false);
    settingsButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    settingsButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    settingsButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        settingsButtonActionPerformed(evt);
      }
    });
    toolBar.add(settingsButton);

    toolbarbuttonGroup.add(helpButton);
    helpButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/help.png"))); // NOI18N
    helpButton.setText("Ajuda");
    helpButton.setFocusable(false);
    helpButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    helpButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    helpButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        helpButtonActionPerformed(evt);
      }
    });
    toolBar.add(helpButton);

    loginPanel.setPreferredSize(new java.awt.Dimension(717, 403));

    prodCloseButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/close.png"))); // NOI18N
    prodCloseButton1.setBorderPainted(false);
    prodCloseButton1.setContentAreaFilled(false);
    prodCloseButton1.setFocusPainted(false);
    prodCloseButton1.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        prodCloseButton1ActionPerformed(evt);
      }
    });

    loginLabel.setFont(new java.awt.Font("Tahoma", 1, 14));
    loginLabel.setText("Login");

    loginUserLabel.setText("Usuário:");

    loginPassLabel.setText("Senha:");

    loginClearButton.setText("Limpar campos");
    loginClearButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        loginClearButtonActionPerformed(evt);
      }
    });

    loginCancelButton.setText("Cancelar");
    loginCancelButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        loginCancelButtonActionPerformed(evt);
      }
    });

    loginOKButton.setText("OK");
    loginOKButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        loginOKButtonActionPerformed(evt);
      }
    });

    javax.swing.GroupLayout loginPanelLayout = new javax.swing.GroupLayout(loginPanel);
    loginPanel.setLayout(loginPanelLayout);
    loginPanelLayout.setHorizontalGroup(
      loginPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(loginPanelLayout.createSequentialGroup()
        .addContainerGap()
        .addGroup(loginPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, loginPanelLayout.createSequentialGroup()
            .addComponent(loginLabel)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 566, Short.MAX_VALUE)
            .addComponent(prodCloseButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
          .addGroup(loginPanelLayout.createSequentialGroup()
            .addGroup(loginPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addComponent(loginUserLabel)
              .addComponent(loginPassLabel))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addGroup(loginPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addComponent(loginPassField, javax.swing.GroupLayout.DEFAULT_SIZE, 589, Short.MAX_VALUE)
              .addComponent(loginUserField, javax.swing.GroupLayout.DEFAULT_SIZE, 589, Short.MAX_VALUE))
            .addGap(10, 10, 10))
          .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, loginPanelLayout.createSequentialGroup()
            .addComponent(loginOKButton)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(loginCancelButton)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(loginClearButton)
            .addContainerGap())))
    );
    loginPanelLayout.setVerticalGroup(
      loginPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(loginPanelLayout.createSequentialGroup()
        .addGroup(loginPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addComponent(prodCloseButton1)
          .addGroup(loginPanelLayout.createSequentialGroup()
            .addContainerGap()
            .addComponent(loginLabel)))
        .addGap(18, 18, 18)
        .addGroup(loginPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(loginUserLabel)
          .addComponent(loginUserField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
        .addGroup(loginPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(loginPassLabel)
          .addComponent(loginPassField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addGap(18, 18, 18)
        .addGroup(loginPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(loginClearButton)
          .addComponent(loginCancelButton)
          .addComponent(loginOKButton))
        .addContainerGap(248, Short.MAX_VALUE))
    );

    helpCloseButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/close.png"))); // NOI18N
    helpCloseButton.setBorderPainted(false);
    helpCloseButton.setContentAreaFilled(false);
    helpCloseButton.setFocusPainted(false);
    helpCloseButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        helpCloseButtonActionPerformed(evt);
      }
    });

    jLabel5.setText("Help .. implementar");

    javax.swing.GroupLayout helpPanelLayout = new javax.swing.GroupLayout(helpPanel);
    helpPanel.setLayout(helpPanelLayout);
    helpPanelLayout.setHorizontalGroup(
      helpPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, helpPanelLayout.createSequentialGroup()
        .addContainerGap()
        .addComponent(jLabel5)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 511, Short.MAX_VALUE)
        .addComponent(helpCloseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
    );
    helpPanelLayout.setVerticalGroup(
      helpPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(helpPanelLayout.createSequentialGroup()
        .addGroup(helpPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addComponent(helpCloseButton)
          .addGroup(helpPanelLayout.createSequentialGroup()
            .addContainerGap()
            .addComponent(jLabel5)))
        .addContainerGap(363, Short.MAX_VALUE))
    );

    settingsCloseButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/close.png"))); // NOI18N
    settingsCloseButton.setBorderPainted(false);
    settingsCloseButton.setContentAreaFilled(false);
    settingsCloseButton.setFocusPainted(false);
    settingsCloseButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        settingsCloseButtonActionPerformed(evt);
      }
    });

    settingsLabel.setFont(new java.awt.Font("Tahoma", 1, 14));
    settingsLabel.setText("Configurações");

    settingsConLabel.setBorder(javax.swing.BorderFactory.createTitledBorder("Conexão"));

    settingsServerLabel.setText("Servidor");

    settingsServerCombobox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "127.0.0.1:1234", "127.0.0.1:9876", "123.45.67.89:1111", "123.45.67.89:9999" }));

    settingsServerConnectButton.setText("Conectar");
    settingsServerConnectButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        settingsServerConnectButtonActionPerformed(evt);
      }
    });

    settingsServerListRefreshButton.setText("Atualizar lista de servidores");

    settingsServerEditButton.setText("Inserir novo servidor");
    settingsServerEditButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        settingsServerEditButtonActionPerformed(evt);
      }
    });

    settingsServerTextField.setText("servidor:porta");
    settingsServerTextField.addFocusListener(new java.awt.event.FocusAdapter() {
      public void focusGained(java.awt.event.FocusEvent evt) {
        settingsServerTextFieldFocusGained(evt);
      }
      public void focusLost(java.awt.event.FocusEvent evt) {
        settingsServerTextFieldFocusLost(evt);
      }
    });

    javax.swing.GroupLayout settingsConLabelLayout = new javax.swing.GroupLayout(settingsConLabel);
    settingsConLabel.setLayout(settingsConLabelLayout);
    settingsConLabelLayout.setHorizontalGroup(
      settingsConLabelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(settingsConLabelLayout.createSequentialGroup()
        .addContainerGap()
        .addComponent(settingsServerLabel)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
        .addGroup(settingsConLabelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
          .addComponent(settingsServerTextField, javax.swing.GroupLayout.Alignment.LEADING)
          .addComponent(settingsServerCombobox, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        .addGap(18, 18, 18)
        .addGroup(settingsConLabelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addGroup(settingsConLabelLayout.createSequentialGroup()
            .addComponent(settingsServerConnectButton)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(settingsServerListRefreshButton))
          .addComponent(settingsServerEditButton))
        .addContainerGap(172, Short.MAX_VALUE))
    );
    settingsConLabelLayout.setVerticalGroup(
      settingsConLabelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(settingsConLabelLayout.createSequentialGroup()
        .addContainerGap()
        .addGroup(settingsConLabelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(settingsServerLabel)
          .addComponent(settingsServerCombobox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
          .addComponent(settingsServerConnectButton)
          .addComponent(settingsServerListRefreshButton))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
        .addGroup(settingsConLabelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(settingsServerTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
          .addComponent(settingsServerEditButton))
        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );

    javax.swing.GroupLayout settingsPanelLayout = new javax.swing.GroupLayout(settingsPanel);
    settingsPanel.setLayout(settingsPanelLayout);
    settingsPanelLayout.setHorizontalGroup(
      settingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(settingsPanelLayout.createSequentialGroup()
        .addContainerGap()
        .addGroup(settingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addGroup(settingsPanelLayout.createSequentialGroup()
            .addComponent(settingsConLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGap(10, 10, 10))
          .addGroup(settingsPanelLayout.createSequentialGroup()
            .addComponent(settingsLabel)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 505, Short.MAX_VALUE)
            .addComponent(settingsCloseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))))
    );
    settingsPanelLayout.setVerticalGroup(
      settingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(settingsPanelLayout.createSequentialGroup()
        .addGroup(settingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addComponent(settingsCloseButton)
          .addGroup(settingsPanelLayout.createSequentialGroup()
            .addContainerGap()
            .addComponent(settingsLabel)))
        .addGap(18, 18, 18)
        .addComponent(settingsConLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addContainerGap(235, Short.MAX_VALUE))
    );

    calendarCloseButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/close.png"))); // NOI18N
    calendarCloseButton.setBorderPainted(false);
    calendarCloseButton.setContentAreaFilled(false);
    calendarCloseButton.setFocusPainted(false);
    calendarCloseButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        calendarCloseButtonActionPerformed(evt);
      }
    });

    calendarLabel.setFont(new java.awt.Font("Tahoma", 1, 14));
    calendarLabel.setText("Calendário");

    calendarTable.setModel(new javax.swing.table.DefaultTableModel(
      new Object [][] {
        {null, null, null, null},
        {null, null, null, null},
        {null, null, null, null},
        {null, null, null, null}
      },
      new String [] {
        "Title 1", "Title 2", "Title 3", "Title 4"
      }
    ));
    calendarTable.setColumnSelectionAllowed(true);
    calendarScrollPane.setViewportView(calendarTable);

    calendarNextButton.setText("»");
    calendarNextButton.setContentAreaFilled(false);
    calendarNextButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        calendarNextButtonActionPerformed(evt);
      }
    });

    calendarPreviousButton.setText("«");
    calendarPreviousButton.setContentAreaFilled(false);
    calendarPreviousButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        calendarPreviousButtonActionPerformed(evt);
      }
    });

    calendarMonthAndYearLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    calendarMonthAndYearLabel.setText("mês");

    calendarTodayButton.setText("Hoje");
    calendarTodayButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        calendarTodayButtonActionPerformed(evt);
      }
    });

    calendarGoButton.setText("Ir");
    calendarGoButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        calendarGoButtonActionPerformed(evt);
      }
    });

    calendarMonthComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Selecionar mês", "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro" }));

    calendarYearTextfield.setText("Selecionar ano");
    calendarYearTextfield.addFocusListener(new java.awt.event.FocusAdapter() {
      public void focusGained(java.awt.event.FocusEvent evt) {
        calendarYearTextfieldFocusGained(evt);
      }
      public void focusLost(java.awt.event.FocusEvent evt) {
        calendarYearTextfieldFocusLost(evt);
      }
    });

    javax.swing.GroupLayout calendarPanelLayout = new javax.swing.GroupLayout(calendarPanel);
    calendarPanel.setLayout(calendarPanelLayout);
    calendarPanelLayout.setHorizontalGroup(
      calendarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(calendarPanelLayout.createSequentialGroup()
        .addContainerGap()
        .addGroup(calendarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addGroup(calendarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(calendarPanelLayout.createSequentialGroup()
              .addComponent(calendarLabel)
              .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 531, Short.MAX_VALUE)
              .addComponent(calendarCloseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, calendarPanelLayout.createSequentialGroup()
              .addComponent(calendarPreviousButton)
              .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
              .addComponent(calendarMonthAndYearLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 547, Short.MAX_VALUE)
              .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
              .addComponent(calendarNextButton)
              .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, calendarPanelLayout.createSequentialGroup()
              .addComponent(calendarScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 633, javax.swing.GroupLayout.PREFERRED_SIZE)
              .addContainerGap()))
          .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, calendarPanelLayout.createSequentialGroup()
            .addComponent(calendarMonthComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
            .addComponent(calendarYearTextfield, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
            .addComponent(calendarGoButton)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
            .addComponent(calendarTodayButton)
            .addContainerGap())))
    );
    calendarPanelLayout.setVerticalGroup(
      calendarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(calendarPanelLayout.createSequentialGroup()
        .addGroup(calendarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addComponent(calendarCloseButton)
          .addGroup(calendarPanelLayout.createSequentialGroup()
            .addContainerGap()
            .addComponent(calendarLabel)))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(calendarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(calendarNextButton)
          .addComponent(calendarPreviousButton)
          .addComponent(calendarMonthAndYearLabel))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        .addComponent(calendarScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 213, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(calendarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(calendarTodayButton)
          .addComponent(calendarGoButton)
          .addComponent(calendarMonthComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
          .addComponent(calendarYearTextfield, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addGap(85, 85, 85))
    );

    phonesCloseButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/close.png"))); // NOI18N
    phonesCloseButton.setBorderPainted(false);
    phonesCloseButton.setContentAreaFilled(false);
    phonesCloseButton.setFocusPainted(false);
    phonesCloseButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        phonesCloseButtonActionPerformed(evt);
      }
    });

    phonesRefreshButton.setText("Atualizar");
    phonesRefreshButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        phonesRefreshButtonActionPerformed(evt);
      }
    });

    phonesSaveButton.setText("Salvar Alterações");
    phonesSaveButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        phonesSaveButtonActionPerformed(evt);
      }
    });

    phonesLabel.setFont(new java.awt.Font("Tahoma", 1, 14));
    phonesLabel.setText("Contatos");

    phonesTable.setModel(new javax.swing.table.DefaultTableModel(
      new Object [][] {
        {null, null, null, null},
        {null, null, null, null},
        {null, null, null, null},
        {null, null, null, null}
      },
      new String [] {
        "Title 1", "Title 2", "Title 3", "Title 4"
      }
    ));
    phonesTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    phonesTableScrollPane.setViewportView(phonesTable);

    javax.swing.GroupLayout phonesPanelLayout = new javax.swing.GroupLayout(phonesPanel);
    phonesPanel.setLayout(phonesPanelLayout);
    phonesPanelLayout.setHorizontalGroup(
      phonesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(phonesPanelLayout.createSequentialGroup()
        .addContainerGap(433, Short.MAX_VALUE)
        .addGroup(phonesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addComponent(phonesCloseButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
          .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, phonesPanelLayout.createSequentialGroup()
            .addComponent(phonesSaveButton)
            .addGap(18, 18, 18)
            .addComponent(phonesRefreshButton)
            .addContainerGap())))
      .addGroup(phonesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(phonesPanelLayout.createSequentialGroup()
          .addContainerGap()
          .addGroup(phonesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(phonesPanelLayout.createSequentialGroup()
              .addComponent(phonesTableScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 633, Short.MAX_VALUE)
              .addContainerGap())
            .addGroup(phonesPanelLayout.createSequentialGroup()
              .addComponent(phonesLabel)
              .addGap(579, 579, 579)))))
    );
    phonesPanelLayout.setVerticalGroup(
      phonesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(phonesPanelLayout.createSequentialGroup()
        .addComponent(phonesCloseButton)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 329, Short.MAX_VALUE)
        .addGroup(phonesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(phonesRefreshButton)
          .addComponent(phonesSaveButton))
        .addContainerGap())
      .addGroup(phonesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(phonesPanelLayout.createSequentialGroup()
          .addGap(14, 14, 14)
          .addComponent(phonesLabel)
          .addGap(18, 18, 18)
          .addComponent(phonesTableScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 314, Short.MAX_VALUE)
          .addGap(40, 40, 40)))
    );

    dbCloseButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/close.png"))); // NOI18N
    dbCloseButton.setBorderPainted(false);
    dbCloseButton.setContentAreaFilled(false);
    dbCloseButton.setFocusPainted(false);
    dbCloseButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        dbCloseButtonActionPerformed(evt);
      }
    });

    dbLabel.setFont(new java.awt.Font("Tahoma", 1, 14));
    dbLabel.setText("Banco de Dados");

    dbSynchButton.setText("Sincronizar Bancos de Dados");
    dbSynchButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        dbSynchButtonActionPerformed(evt);
      }
    });

    javax.swing.GroupLayout dbPanelLayout = new javax.swing.GroupLayout(dbPanel);
    dbPanel.setLayout(dbPanelLayout);
    dbPanelLayout.setHorizontalGroup(
      dbPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(dbPanelLayout.createSequentialGroup()
        .addContainerGap()
        .addGroup(dbPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, dbPanelLayout.createSequentialGroup()
            .addComponent(dbLabel)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 493, Short.MAX_VALUE)
            .addComponent(dbCloseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
          .addGroup(dbPanelLayout.createSequentialGroup()
            .addComponent(dbSynchButton)
            .addContainerGap(474, Short.MAX_VALUE))))
    );
    dbPanelLayout.setVerticalGroup(
      dbPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(dbPanelLayout.createSequentialGroup()
        .addGroup(dbPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addComponent(dbCloseButton)
          .addGroup(dbPanelLayout.createSequentialGroup()
            .addContainerGap()
            .addComponent(dbLabel)))
        .addGap(18, 18, 18)
        .addComponent(dbSynchButton)
        .addContainerGap(318, Short.MAX_VALUE))
    );

    chartsCloseButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/close.png"))); // NOI18N
    chartsCloseButton.setBorderPainted(false);
    chartsCloseButton.setContentAreaFilled(false);
    chartsCloseButton.setFocusPainted(false);
    chartsCloseButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        chartsCloseButtonActionPerformed(evt);
      }
    });

    chartsLabel.setFont(new java.awt.Font("Tahoma", 1, 14));
    chartsLabel.setText("Gráficos");

    javax.swing.GroupLayout chartsSalesPanelLayout = new javax.swing.GroupLayout(chartsSalesPanel);
    chartsSalesPanel.setLayout(chartsSalesPanelLayout);
    chartsSalesPanelLayout.setHorizontalGroup(
      chartsSalesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(chartsSalesPanelLayout.createSequentialGroup()
        .addContainerGap()
        .addComponent(chartSalesLabel)
        .addContainerGap(618, Short.MAX_VALUE))
    );
    chartsSalesPanelLayout.setVerticalGroup(
      chartsSalesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(chartsSalesPanelLayout.createSequentialGroup()
        .addComponent(chartSalesLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 291, Short.MAX_VALUE)
        .addContainerGap())
    );

    chartsTabbedPane.addTab("Vendas", chartsSalesPanel);

    javax.swing.GroupLayout chartsRequestsPanelLayout = new javax.swing.GroupLayout(chartsRequestsPanel);
    chartsRequestsPanel.setLayout(chartsRequestsPanelLayout);
    chartsRequestsPanelLayout.setHorizontalGroup(
      chartsRequestsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(chartsRequestsPanelLayout.createSequentialGroup()
        .addContainerGap()
        .addComponent(chartRequestsLabel)
        .addContainerGap(618, Short.MAX_VALUE))
    );
    chartsRequestsPanelLayout.setVerticalGroup(
      chartsRequestsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(chartsRequestsPanelLayout.createSequentialGroup()
        .addComponent(chartRequestsLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 291, Short.MAX_VALUE)
        .addContainerGap())
    );

    chartsTabbedPane.addTab("Requisições", chartsRequestsPanel);

    javax.swing.GroupLayout chartsPanelLayout = new javax.swing.GroupLayout(chartsPanel);
    chartsPanel.setLayout(chartsPanelLayout);
    chartsPanelLayout.setHorizontalGroup(
      chartsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(chartsPanelLayout.createSequentialGroup()
        .addContainerGap()
        .addGroup(chartsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addGroup(chartsPanelLayout.createSequentialGroup()
            .addComponent(chartsTabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 633, Short.MAX_VALUE)
            .addGap(10, 10, 10))
          .addGroup(chartsPanelLayout.createSequentialGroup()
            .addComponent(chartsLabel)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 549, Short.MAX_VALUE)
            .addComponent(chartsCloseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))))
    );
    chartsPanelLayout.setVerticalGroup(
      chartsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(chartsPanelLayout.createSequentialGroup()
        .addGroup(chartsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addComponent(chartsCloseButton)
          .addGroup(chartsPanelLayout.createSequentialGroup()
            .addContainerGap()
            .addComponent(chartsLabel)))
        .addGap(18, 18, 18)
        .addComponent(chartsTabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 330, Short.MAX_VALUE)
        .addContainerGap())
    );

    salesCloseButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/close.png"))); // NOI18N
    salesCloseButton.setBorderPainted(false);
    salesCloseButton.setContentAreaFilled(false);
    salesCloseButton.setFocusPainted(false);
    salesCloseButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        salesCloseButtonActionPerformed(evt);
      }
    });

    salesLabel.setFont(new java.awt.Font("Tahoma", 1, 14));
    salesLabel.setText("Vendas");

    salesTable.setModel(new javax.swing.table.DefaultTableModel(
      new Object [][] {
        {null, null, null, null},
        {null, null, null, null},
        {null, null, null, null},
        {null, null, null, null}
      },
      new String [] {
        "Title 1", "Title 2", "Title 3", "Title 4"
      }
    ));
    salesTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    salesTableScrollPane.setViewportView(salesTable);

    salesRefreshButton.setText("Atualizar");
    salesRefreshButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        salesRefreshButtonActionPerformed(evt);
      }
    });

    salesCreateChartButton.setText("Gerar gráfico");
    salesCreateChartButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        salesCreateChartButtonActionPerformed(evt);
      }
    });

    salesSelectAllButton.setText("Selecionar Tudo");
    salesSelectAllButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        salesSelectAllButtonActionPerformed(evt);
      }
    });

    javax.swing.GroupLayout salesPanelLayout = new javax.swing.GroupLayout(salesPanel);
    salesPanel.setLayout(salesPanelLayout);
    salesPanelLayout.setHorizontalGroup(
      salesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, salesPanelLayout.createSequentialGroup()
        .addContainerGap()
        .addComponent(salesLabel)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 553, Short.MAX_VALUE)
        .addComponent(salesCloseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
      .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, salesPanelLayout.createSequentialGroup()
        .addGap(20, 20, 20)
        .addComponent(salesTableScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 623, Short.MAX_VALUE)
        .addContainerGap())
      .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, salesPanelLayout.createSequentialGroup()
        .addContainerGap(352, Short.MAX_VALUE)
        .addComponent(salesRefreshButton)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(salesSelectAllButton)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(salesCreateChartButton)
        .addContainerGap())
    );
    salesPanelLayout.setVerticalGroup(
      salesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(salesPanelLayout.createSequentialGroup()
        .addGroup(salesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addComponent(salesCloseButton)
          .addGroup(salesPanelLayout.createSequentialGroup()
            .addContainerGap()
            .addComponent(salesLabel)))
        .addGap(18, 18, 18)
        .addComponent(salesTableScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 299, Short.MAX_VALUE)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(salesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(salesCreateChartButton)
          .addComponent(salesSelectAllButton)
          .addComponent(salesRefreshButton))
        .addContainerGap())
    );

    prodPanel.setPreferredSize(new java.awt.Dimension(717, 403));

    prodLabel.setFont(new java.awt.Font("Tahoma", 1, 14));
    prodLabel.setText("Produtos");

    prodCloseButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/close.png"))); // NOI18N
    prodCloseButton.setBorderPainted(false);
    prodCloseButton.setContentAreaFilled(false);
    prodCloseButton.setFocusPainted(false);
    prodCloseButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        prodCloseButtonActionPerformed(evt);
      }
    });

    prodTable.setModel(new javax.swing.table.DefaultTableModel(
      new Object [][] {
        {null, null, null, null},
        {null, null, null, null},
        {null, null, null, null},
        {null, null, null, null}
      },
      new String [] {
        "Title 1", "Title 2", "Title 3", "Title 4"
      }
    ));
    prodTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    prodTableScrollPane.setViewportView(prodTable);

    prodRefreshButton.setText("Atualizar");
    prodRefreshButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        prodRefreshButtonActionPerformed(evt);
      }
    });

    prodDevButton.setText("Devolver todos os produtos");
    prodDevButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        prodDevButtonActionPerformed(evt);
      }
    });

    javax.swing.GroupLayout prodPanelLayout = new javax.swing.GroupLayout(prodPanel);
    prodPanel.setLayout(prodPanelLayout);
    prodPanelLayout.setHorizontalGroup(
      prodPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, prodPanelLayout.createSequentialGroup()
        .addContainerGap()
        .addComponent(prodLabel)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 604, Short.MAX_VALUE)
        .addComponent(prodCloseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
      .addGroup(prodPanelLayout.createSequentialGroup()
        .addGap(20, 20, 20)
        .addComponent(prodTableScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 687, Short.MAX_VALUE)
        .addGap(10, 10, 10))
      .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, prodPanelLayout.createSequentialGroup()
        .addContainerGap(457, Short.MAX_VALUE)
        .addComponent(prodDevButton)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
        .addComponent(prodRefreshButton)
        .addContainerGap())
    );
    prodPanelLayout.setVerticalGroup(
      prodPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(prodPanelLayout.createSequentialGroup()
        .addGroup(prodPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addComponent(prodCloseButton)
          .addGroup(prodPanelLayout.createSequentialGroup()
            .addContainerGap()
            .addComponent(prodLabel)))
        .addGap(18, 18, 18)
        .addComponent(prodTableScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 305, Short.MAX_VALUE)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addGroup(prodPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(prodRefreshButton)
          .addComponent(prodDevButton))
        .addContainerGap())
    );

    jLabel2.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
    jLabel2.setText("Bem vindo ao SMS - Pharm Edition");

    jScrollPane1.setEnabled(false);

    jTextArea1.setBackground(new java.awt.Color(224, 223, 227));
    jTextArea1.setColumns(20);
    jTextArea1.setFont(new java.awt.Font("Verdana", 0, 13)); // NOI18N
    jTextArea1.setRows(5);
    jTextArea1.setText("Você pode executar algumas ações:\n + Reservar Produtos do servidor\n + Vender Produtos reservados anteriormente\n + Verificar gráficos de seus progressos\n + Verificar sua agenda\n + Verificar Calendário com seus compromissos\n + Entre outras ações...\n\nSe estiver em dúvidas quanto ao funcionamento, clique em 'Ajuda'.");
    jScrollPane1.setViewportView(jTextArea1);

    javax.swing.GroupLayout defaultPanelLayout = new javax.swing.GroupLayout(defaultPanel);
    defaultPanel.setLayout(defaultPanelLayout);
    defaultPanelLayout.setHorizontalGroup(
      defaultPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(defaultPanelLayout.createSequentialGroup()
        .addGroup(defaultPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addGroup(defaultPanelLayout.createSequentialGroup()
            .addGap(10, 10, 10)
            .addComponent(jLabel2))
          .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, defaultPanelLayout.createSequentialGroup()
            .addContainerGap()
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 633, Short.MAX_VALUE)))
        .addContainerGap())
    );
    defaultPanelLayout.setVerticalGroup(
      defaultPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(defaultPanelLayout.createSequentialGroup()
        .addContainerGap()
        .addComponent(jLabel2)
        .addGap(18, 18, 18)
        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 201, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addContainerGap(121, Short.MAX_VALUE))
    );

    javax.swing.GroupLayout contentPanelLayout = new javax.swing.GroupLayout(contentPanel);
    contentPanel.setLayout(contentPanelLayout);
    contentPanelLayout.setHorizontalGroup(
      contentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(contentPanelLayout.createSequentialGroup()
        .addContainerGap()
        .addComponent(defaultPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        .addContainerGap())
      .addGroup(contentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(contentPanelLayout.createSequentialGroup()
          .addContainerGap()
          .addComponent(prodPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          .addContainerGap()))
      .addGroup(contentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(contentPanelLayout.createSequentialGroup()
          .addContainerGap()
          .addComponent(salesPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          .addContainerGap()))
      .addGroup(contentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(contentPanelLayout.createSequentialGroup()
          .addContainerGap()
          .addComponent(dbPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          .addContainerGap()))
      .addGroup(contentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(contentPanelLayout.createSequentialGroup()
          .addContainerGap()
          .addComponent(chartsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          .addContainerGap()))
      .addGroup(contentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(contentPanelLayout.createSequentialGroup()
          .addContainerGap()
          .addComponent(helpPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          .addContainerGap()))
      .addGroup(contentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(contentPanelLayout.createSequentialGroup()
          .addContainerGap()
          .addComponent(settingsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          .addContainerGap()))
      .addGroup(contentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(contentPanelLayout.createSequentialGroup()
          .addContainerGap()
          .addComponent(calendarPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          .addContainerGap()))
      .addGroup(contentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(contentPanelLayout.createSequentialGroup()
          .addContainerGap()
          .addComponent(phonesPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          .addContainerGap()))
      .addGroup(contentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(contentPanelLayout.createSequentialGroup()
          .addContainerGap()
          .addComponent(loginPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 653, Short.MAX_VALUE)
          .addContainerGap()))
    );
    contentPanelLayout.setVerticalGroup(
      contentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(contentPanelLayout.createSequentialGroup()
        .addComponent(defaultPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        .addGap(41, 41, 41))
      .addGroup(contentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(contentPanelLayout.createSequentialGroup()
          .addComponent(prodPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          .addGap(8, 8, 8)))
      .addGroup(contentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(contentPanelLayout.createSequentialGroup()
          .addComponent(salesPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          .addGap(17, 17, 17)))
      .addGroup(contentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(contentPanelLayout.createSequentialGroup()
          .addComponent(dbPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          .addGap(15, 15, 15)))
      .addGroup(contentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(contentPanelLayout.createSequentialGroup()
          .addComponent(chartsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          .addGap(15, 15, 15)))
      .addGroup(contentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(contentPanelLayout.createSequentialGroup()
          .addComponent(helpPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          .addContainerGap()))
      .addGroup(contentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(contentPanelLayout.createSequentialGroup()
          .addComponent(settingsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          .addGap(12, 12, 12)))
      .addGroup(contentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(contentPanelLayout.createSequentialGroup()
          .addComponent(calendarPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          .addGap(12, 12, 12)))
      .addGroup(contentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(contentPanelLayout.createSequentialGroup()
          .addComponent(phonesPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          .addContainerGap()))
      .addGroup(contentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(contentPanelLayout.createSequentialGroup()
          .addComponent(loginPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 398, Short.MAX_VALUE)
          .addGap(16, 16, 16)))
    );

    loginToolbar.setFloatable(false);
    loginToolbar.setRollover(true);

    loginButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/disconnected.png"))); // NOI18N
    loginButton.setText("Offline");
    loginButton.setFocusable(false);
    loginButton.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
    loginButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    loginButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        loginButtonActionPerformed(evt);
      }
    });
    loginToolbar.add(loginButton);

    javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
    mainPanel.setLayout(mainPanelLayout);
    mainPanelLayout.setHorizontalGroup(
      mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addComponent(toolBar, javax.swing.GroupLayout.DEFAULT_SIZE, 673, Short.MAX_VALUE)
      .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 673, Short.MAX_VALUE)
      .addComponent(contentPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
      .addComponent(loginToolbar, javax.swing.GroupLayout.DEFAULT_SIZE, 673, Short.MAX_VALUE)
    );
    mainPanelLayout.setVerticalGroup(
      mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(mainPanelLayout.createSequentialGroup()
        .addComponent(toolBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(contentPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(loginToolbar, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
    );

    jMenu1.setText("Arquivo");

    jMenuItem1.setText("Efetuar login");
    jMenu1.add(jMenuItem1);

    menuBar.add(jMenu1);

    jMenu3.setText("Opções");

    jMenu4.setText("Modificar tema");

    jMenuItem4.setText("Autumn");
    jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jMenuItem4ActionPerformed(evt);
      }
    });
    jMenu4.add(jMenuItem4);

    jMenu5.setText("Business");

    jMenuItem13.setText("Business");
    jMenuItem13.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jMenuItem13ActionPerformed(evt);
      }
    });
    jMenu5.add(jMenuItem13);

    jMenuItem11.setText("Business Black");
    jMenuItem11.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jMenuItem11ActionPerformed(evt);
      }
    });
    jMenu5.add(jMenuItem11);

    jMenuItem12.setText("Business Blue");
    jMenuItem12.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jMenuItem12ActionPerformed(evt);
      }
    });
    jMenu5.add(jMenuItem12);

    jMenu4.add(jMenu5);

    jMenuItem10.setText("Challenger");
    jMenuItem10.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jMenuItem10ActionPerformed(evt);
      }
    });
    jMenu4.add(jMenuItem10);

    jMenu6.setText("Creme");

    jMenuItem9.setText("Creme");
    jMenuItem9.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jMenuItem9ActionPerformed(evt);
      }
    });
    jMenu6.add(jMenuItem9);

    jMenuItem3.setText("Creme Coffee");
    jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jMenuItem3ActionPerformed(evt);
      }
    });
    jMenu6.add(jMenuItem3);

    jMenu4.add(jMenu6);

    jMenuItem8.setText("Emerald Dusk");
    jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jMenuItem8ActionPerformed(evt);
      }
    });
    jMenu4.add(jMenuItem8);

    jMenuItem7.setText("Legacy Default");
    jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jMenuItem7ActionPerformed(evt);
      }
    });
    jMenu4.add(jMenuItem7);

    jMenuItem6.setText("Magma");
    jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jMenuItem6ActionPerformed(evt);
      }
    });
    jMenu4.add(jMenuItem6);

    jMenu7.setText("Mist");

    jMenuItem5.setText("Mist Aqua");
    jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jMenuItem5ActionPerformed(evt);
      }
    });
    jMenu7.add(jMenuItem5);

    jMenuItem17.setText("Mist Silver");
    jMenuItem17.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jMenuItem17ActionPerformed(evt);
      }
    });
    jMenu7.add(jMenuItem17);

    jMenu4.add(jMenu7);

    jMenuItem16.setText("Moderate (padrão)");
    jMenuItem16.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jMenuItem16ActionPerformed(evt);
      }
    });
    jMenu4.add(jMenuItem16);

    jMenu8.setText("Nebula");

    jMenuItem18.setText("Nebula");
    jMenuItem18.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jMenuItem18ActionPerformed(evt);
      }
    });
    jMenu8.add(jMenuItem18);

    jMenuItem15.setText("Nebula Brick Wall");
    jMenuItem15.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jMenuItem15ActionPerformed(evt);
      }
    });
    jMenu8.add(jMenuItem15);

    jMenu4.add(jMenu8);

    jMenu9.setText("Office 2007");

    jMenuItem14.setText("Office Blue 2007");
    jMenuItem14.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jMenuItem14ActionPerformed(evt);
      }
    });
    jMenu9.add(jMenuItem14);

    jMenuItem19.setText("Office Silver 2007");
    jMenuItem19.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jMenuItem19ActionPerformed(evt);
      }
    });
    jMenu9.add(jMenuItem19);

    jMenu4.add(jMenu9);

    jMenu10.setText("Raven");

    jMenuItem22.setText("Raven");
    jMenuItem22.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jMenuItem22ActionPerformed(evt);
      }
    });
    jMenu10.add(jMenuItem22);

    jMenuItem2.setText("Raven Graphite");
    jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jMenuItem2ActionPerformed(evt);
      }
    });
    jMenu10.add(jMenuItem2);

    jMenuItem21.setText("Raven Graphite Glass");
    jMenuItem21.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jMenuItem21ActionPerformed(evt);
      }
    });
    jMenu10.add(jMenuItem21);

    jMenu4.add(jMenu10);

    jMenuItem23.setText("Sahara");
    jMenuItem23.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jMenuItem23ActionPerformed(evt);
      }
    });
    jMenu4.add(jMenuItem23);

    jMenu3.add(jMenu4);

    menuBar.add(jMenu3);

    jMenu11.setText("Ajuda");

    jMenuItem20.setText("Sobre");
    jMenuItem20.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jMenuItem20ActionPerformed(evt);
      }
    });
    jMenu11.add(jMenuItem20);

    menuBar.add(jMenu11);

    setJMenuBar(menuBar);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addComponent(mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    );
    layout.setVerticalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(layout.createSequentialGroup()
        .addComponent(mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        .addContainerGap())
    );

    java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    setBounds((screenSize.width-668)/2, (screenSize.height-620)/2, 668, 620);
  }// </editor-fold>//GEN-END:initComponents

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
      try {
        UIManager.setLookAndFeel(new SubstanceRavenGraphiteLookAndFeel());
        SwingUtilities.updateComponentTreeUI(this);
        pack();
        pack();
      } catch (UnsupportedLookAndFeelException ex) {
        //***CATCH***//
      }
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
      try {
        UIManager.setLookAndFeel(new SubstanceCremeCoffeeLookAndFeel());
        SwingUtilities.updateComponentTreeUI(this);
        pack();
      } catch (UnsupportedLookAndFeelException ex) {
        //***CATCH***//
      }
    }//GEN-LAST:event_jMenuItem3ActionPerformed

    private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
      try {
        UIManager.setLookAndFeel(new SubstanceAutumnLookAndFeel());
        SwingUtilities.updateComponentTreeUI(this);
        pack();
      } catch (UnsupportedLookAndFeelException ex) {
        //***CATCH***//
      }
    }//GEN-LAST:event_jMenuItem4ActionPerformed

    private void jMenuItem10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem10ActionPerformed
      try {
        UIManager.setLookAndFeel(new SubstanceChallengerDeepLookAndFeel());
        SwingUtilities.updateComponentTreeUI(this);
        pack();
      } catch (UnsupportedLookAndFeelException ex) {
        //***CATCH***//
      }
    }//GEN-LAST:event_jMenuItem10ActionPerformed

    private void jMenuItem11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem11ActionPerformed
      try {
        UIManager.setLookAndFeel(new SubstanceBusinessBlackSteelLookAndFeel());
        SwingUtilities.updateComponentTreeUI(this);
        pack();
      } catch (UnsupportedLookAndFeelException ex) {
        //***CATCH***//
      }
    }//GEN-LAST:event_jMenuItem11ActionPerformed

    private void jMenuItem12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem12ActionPerformed
      try {
        UIManager.setLookAndFeel(new SubstanceBusinessBlueSteelLookAndFeel());
        SwingUtilities.updateComponentTreeUI(this);
        pack();
      } catch (UnsupportedLookAndFeelException ex) {
        //***CATCH***//
      }
    }//GEN-LAST:event_jMenuItem12ActionPerformed

    private void jMenuItem13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem13ActionPerformed
      try {
        UIManager.setLookAndFeel(new SubstanceBusinessLookAndFeel());
        SwingUtilities.updateComponentTreeUI(this);
        pack();
      } catch (UnsupportedLookAndFeelException ex) {
        //***CATCH***//
      }
    }//GEN-LAST:event_jMenuItem13ActionPerformed

    private void jMenuItem9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem9ActionPerformed
      try {
        UIManager.setLookAndFeel(new SubstanceCremeLookAndFeel());
        SwingUtilities.updateComponentTreeUI(this);
        pack();
      } catch (UnsupportedLookAndFeelException ex) {
        //***CATCH***//
      }
    }//GEN-LAST:event_jMenuItem9ActionPerformed

    private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem8ActionPerformed
      try {
        UIManager.setLookAndFeel(new SubstanceEmeraldDuskLookAndFeel());
        SwingUtilities.updateComponentTreeUI(this);
        pack();
      } catch (UnsupportedLookAndFeelException ex) {
        //***CATCH***//
      }
    }//GEN-LAST:event_jMenuItem8ActionPerformed

    private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem7ActionPerformed
      try {
        UIManager.setLookAndFeel(new SubstanceLegacyDefaultLookAndFeel());
        SwingUtilities.updateComponentTreeUI(this);
        pack();
      } catch (UnsupportedLookAndFeelException ex) {
        //***CATCH***//
      }
    }//GEN-LAST:event_jMenuItem7ActionPerformed

    private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed
      try {
        UIManager.setLookAndFeel(new SubstanceMagmaLookAndFeel());
        SwingUtilities.updateComponentTreeUI(this);
        pack();
      } catch (UnsupportedLookAndFeelException ex) {
        //***CATCH***//
      }
    }//GEN-LAST:event_jMenuItem6ActionPerformed

    private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed
      try {
        UIManager.setLookAndFeel(new SubstanceMistAquaLookAndFeel());
        SwingUtilities.updateComponentTreeUI(this);
        pack();
      } catch (UnsupportedLookAndFeelException ex) {
        //***CATCH***//
      }
    }//GEN-LAST:event_jMenuItem5ActionPerformed

    private void jMenuItem17ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem17ActionPerformed
      try {
        UIManager.setLookAndFeel(new SubstanceMistSilverLookAndFeel());
        SwingUtilities.updateComponentTreeUI(this);
        pack();
      } catch (UnsupportedLookAndFeelException ex) {
        //***CATCH***//
      }
    }//GEN-LAST:event_jMenuItem17ActionPerformed

    private void jMenuItem16ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem16ActionPerformed
      try {
        UIManager.setLookAndFeel(new SubstanceModerateLookAndFeel());
        SwingUtilities.updateComponentTreeUI(this);
        pack();
      } catch (UnsupportedLookAndFeelException ex) {
        //***CATCH***//
      }
    }//GEN-LAST:event_jMenuItem16ActionPerformed

    private void jMenuItem15ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem15ActionPerformed
      try {
        UIManager.setLookAndFeel(new SubstanceNebulaBrickWallLookAndFeel());
        SwingUtilities.updateComponentTreeUI(this);
        pack();
      } catch (UnsupportedLookAndFeelException ex) {
        //***CATCH***//
      }
    }//GEN-LAST:event_jMenuItem15ActionPerformed

    private void jMenuItem18ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem18ActionPerformed
      try {
        UIManager.setLookAndFeel(new SubstanceNebulaLookAndFeel());
        SwingUtilities.updateComponentTreeUI(this);
        pack();
      } catch (UnsupportedLookAndFeelException ex) {
        //***CATCH***//
      }
    }//GEN-LAST:event_jMenuItem18ActionPerformed

    private void jMenuItem14ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem14ActionPerformed
      try {
        UIManager.setLookAndFeel(new SubstanceOfficeBlue2007LookAndFeel());
        SwingUtilities.updateComponentTreeUI(this);
        pack();
      } catch (UnsupportedLookAndFeelException ex) {
        //***CATCH***//
      }
    }//GEN-LAST:event_jMenuItem14ActionPerformed

    private void jMenuItem19ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem19ActionPerformed
      try {
        UIManager.setLookAndFeel(new SubstanceOfficeSilver2007LookAndFeel());
        SwingUtilities.updateComponentTreeUI(this);
        pack();
      } catch (UnsupportedLookAndFeelException ex) {
        //***CATCH***//
      }
    }//GEN-LAST:event_jMenuItem19ActionPerformed

    private void jMenuItem22ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem22ActionPerformed
      try {
        UIManager.setLookAndFeel(new SubstanceRavenLookAndFeel());
        SwingUtilities.updateComponentTreeUI(this);
        pack();
      } catch (UnsupportedLookAndFeelException ex) {
        //***CATCH***//
      }
    }//GEN-LAST:event_jMenuItem22ActionPerformed

    private void jMenuItem21ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem21ActionPerformed
      try {
        UIManager.setLookAndFeel(new SubstanceRavenGraphiteGlassLookAndFeel());
        SwingUtilities.updateComponentTreeUI(this);
        pack();
      } catch (UnsupportedLookAndFeelException ex) {
        //***CATCH***//
      }
    }//GEN-LAST:event_jMenuItem21ActionPerformed

    private void jMenuItem23ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem23ActionPerformed
      try {
        UIManager.setLookAndFeel(new SubstanceSaharaLookAndFeel());
        SwingUtilities.updateComponentTreeUI(this);
        pack();
      } catch (UnsupportedLookAndFeelException ex) {
        //***CATCH***//
      }
    }//GEN-LAST:event_jMenuItem23ActionPerformed

    private void loginButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loginButtonActionPerformed
      showPanel(loginPanel);
}//GEN-LAST:event_loginButtonActionPerformed

    private void prodButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_prodButtonActionPerformed
      createProdTable();
      showPanel(prodPanel);
}//GEN-LAST:event_prodButtonActionPerformed

    private void salesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_salesButtonActionPerformed
      createSalesTable();
      showPanel(salesPanel);
}//GEN-LAST:event_salesButtonActionPerformed

    private void chartsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chartsButtonActionPerformed

      Object[][] data = Sales.getSalesChartData();
      Object[][] req = Sales.getReqChartData();
      XYSeries seriesV = new XYSeries("Vendas");
      XYSeries seriesR = new XYSeries("Requisições");

      for (int i = 0; i < data.length; i++) {
        seriesV.add(i + 1, (Integer) data[i][1]);
      }

      for (int i = 0; i < req.length; i++) {
        seriesR.add(i + 1, (Integer) req[i][1]);
      }


      chartSalesLabel.setIcon(new ImageIcon(Chart.getSalesChart(seriesV, 500, 300)));
      chartRequestsLabel.setIcon(new ImageIcon(Chart.getReqChart(seriesR, 500, 300)));
      showPanel(chartsPanel);
    }//GEN-LAST:event_chartsButtonActionPerformed

    private void dbButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dbButtonActionPerformed
      showPanel(dbPanel);
    }//GEN-LAST:event_dbButtonActionPerformed

    private void phoneButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_phoneButtonActionPerformed
      createPhonesTable();
      showPanel(phonesPanel);
    }//GEN-LAST:event_phoneButtonActionPerformed

    private void calendarButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_calendarButtonActionPerformed
      showCalendar(0);
      showPanel(calendarPanel);
    }//GEN-LAST:event_calendarButtonActionPerformed

    private void settingsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_settingsButtonActionPerformed
      settingsServerCombobox.setModel(new javax.swing.DefaultComboBoxModel(Server.getServers()));
      showPanel(settingsPanel);
    }//GEN-LAST:event_settingsButtonActionPerformed

    private void helpButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_helpButtonActionPerformed
      showPanel(helpPanel);
    }//GEN-LAST:event_helpButtonActionPerformed

    private void prodCloseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_prodCloseButtonActionPerformed
      showPanel(null);
}//GEN-LAST:event_prodCloseButtonActionPerformed

    private void salesCloseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_salesCloseButtonActionPerformed
      showPanel(null);
}//GEN-LAST:event_salesCloseButtonActionPerformed

    private void chartsCloseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chartsCloseButtonActionPerformed
      showPanel(null);
}//GEN-LAST:event_chartsCloseButtonActionPerformed

    private void dbCloseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dbCloseButtonActionPerformed
      showPanel(null);
}//GEN-LAST:event_dbCloseButtonActionPerformed

    private void phonesCloseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_phonesCloseButtonActionPerformed
      showPanel(null);
}//GEN-LAST:event_phonesCloseButtonActionPerformed

    private void calendarCloseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_calendarCloseButtonActionPerformed
      showPanel(null);
}//GEN-LAST:event_calendarCloseButtonActionPerformed

    private void settingsCloseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_settingsCloseButtonActionPerformed
      showPanel(null);
}//GEN-LAST:event_settingsCloseButtonActionPerformed

    private void helpCloseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_helpCloseButtonActionPerformed
      showPanel(null);
}//GEN-LAST:event_helpCloseButtonActionPerformed

    private void prodCloseButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_prodCloseButton1ActionPerformed
      showPanel(null);
    }//GEN-LAST:event_prodCloseButton1ActionPerformed

    private void loginClearButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loginClearButtonActionPerformed
      loginUserField.setText("");
      loginPassField.setText("");
}//GEN-LAST:event_loginClearButtonActionPerformed

    private void loginCancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loginCancelButtonActionPerformed
      showPanel(null);
}//GEN-LAST:event_loginCancelButtonActionPerformed

    private void loginOKButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loginOKButtonActionPerformed
      if (User.login(loginUserField.getText(), new String(loginPassField.getPassword()))) {
        loginButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/connected.png")));
        Locale locale = Locale.getDefault();
        DateFormat formatter = new SimpleDateFormat("E, dd MMMM yyyy HH:mm:ss", locale);
        String s = formatter.format(new Date());
        loginButton.setText("Online desde " + s);
      } else {
        JOptionPane.showMessageDialog(this, "O login falhou.\nConfira os dados e tente novamente",
                "Erro ao efetuar login", JOptionPane.ERROR_MESSAGE);
        loginButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/disconnected.png")));
        loginButton.setText("Offline");
      }
}//GEN-LAST:event_loginOKButtonActionPerformed

    private void prodRefreshButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_prodRefreshButtonActionPerformed
      refreshProdTable();
    }//GEN-LAST:event_prodRefreshButtonActionPerformed

    private void saleDialogCancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saleDialogCancelButtonActionPerformed
      saleDialog.setVisible(false);
      saleDialog.dispose();
      showPanel(prodPanel);
}//GEN-LAST:event_saleDialogCancelButtonActionPerformed

    private void saleDialogOKButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saleDialogOKButtonActionPerformed

      if(!Communication.isConnected()) return;

      String amount = saleDialogAmountField.getText();
      String[] d = Products.getData(currentProdRow);
      int newValue = Integer.parseInt(amount);
      int oldValue = Integer.parseInt(d[5]);
      if (newValue > oldValue) {
        return;
      }
      // escreve a venda
      Locale locale = Locale.getDefault();
      DateFormat formatter = new SimpleDateFormat("dd/MM/yy HH:mm", locale);
      String s = formatter.format(new Date());

      DataBase.writeData(DataBase.SALES,
              new String[]{d[0], d[1], amount,
                "R$ " + Float.toString(newValue * Float.valueOf(d[3].replace("R$ ", ""))), s});
      // escreve o produto
      if (oldValue - newValue > 0) {
        d[5] = Integer.toString(oldValue - newValue);
        DataBase.writeData(DataBase.PRODUCTS, d);
      } else {
        DataBase.deleteData(DataBase.PRODUCTS, d);
      }

      refreshProdTable();
      saleDialog.setVisible(false);
      saleDialog.dispose();
      showPanel(prodPanel);
}//GEN-LAST:event_saleDialogOKButtonActionPerformed

    private void salesRefreshButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_salesRefreshButtonActionPerformed
      refreshSalesTable();
}//GEN-LAST:event_salesRefreshButtonActionPerformed

    private void salesCreateChartButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_salesCreateChartButtonActionPerformed
      int[] selected = salesTable.getSelectedRows();
      if (selected.length <= 0) {
        return;
      }
      XYSeries seriesA = new XYSeries("Vendas");
      XYSeries seriesT = new XYSeries("Valores");

      Object[][] data = Sales.getSalesChartData();
      dataTable = new String[data.length][4];

      seriesA.clear();
      seriesT.clear();
      for (int i = 0; i < data.length; i++) {
        dataTable[i][0] = String.valueOf(i + 1);
        dataTable[i][1] = String.valueOf(data[i][0]);
        dataTable[i][2] = String.valueOf(data[i][1]);
        dataTable[i][3] = String.valueOf(data[i][2]);
        seriesA.add(i + 1, (Integer) data[i][1]);
        seriesT.add(i + 1, (Float) data[i][2]);
      }

      chart = Chart.getSalesCompositeChart(seriesA, seriesT, 600, 400);
      chartDialogLabel.setIcon(new ImageIcon(chart));
      chartDialogLabel.setBounds(0, 0, 600, 400);
      chartDialog.pack();
      chartDialog.setLocationRelativeTo(null);
      chartDialog.setVisible(true);
}//GEN-LAST:event_salesCreateChartButtonActionPerformed

    private void phonesRefreshButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_phonesRefreshButtonActionPerformed
      refreshPhonesTable();
}//GEN-LAST:event_phonesRefreshButtonActionPerformed

    private void jMenuItem20ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem20ActionPerformed
      aboutDialog.pack();
      aboutDialog.setLocationRelativeTo(null);
      aboutDialog.setVisible(true);
    }//GEN-LAST:event_jMenuItem20ActionPerformed

    private void aboutDialogLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_aboutDialogLabelMouseClicked
      aboutDialog.setVisible(false);
      aboutDialog.dispose();
      showPanel(currentPanel);
}//GEN-LAST:event_aboutDialogLabelMouseClicked

    private void chartDialogMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_chartDialogMouseClicked
      chartDialog.setVisible(false);
      chartDialog.dispose();
      showPanel(currentPanel);
    }//GEN-LAST:event_chartDialogMouseClicked

    private void salesSelectAllButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_salesSelectAllButtonActionPerformed
      salesTable.selectAll();
}//GEN-LAST:event_salesSelectAllButtonActionPerformed

    private void chartCloseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chartCloseButtonActionPerformed
      chartDialog.setVisible(false);
      chartDialog.dispose();
      showPanel(currentPanel);
}//GEN-LAST:event_chartCloseButtonActionPerformed

    private void chartSaveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chartSaveButtonActionPerformed

      JFileChooser fileChooser = new JFileChooser(new File("\\"));
      FileFilter filter = new ExtensionFileFilter("PNG files", "*.png");
      fileChooser.addChoosableFileFilter(filter);

      int returnVal = fileChooser.showSaveDialog(this);

      try {
        if(returnVal == JFileChooser.APPROVE_OPTION)
          ImageIO.write(chart, "png", fileChooser.getSelectedFile());
      } catch (IOException ex) {
        ex.printStackTrace();
      }
}//GEN-LAST:event_chartSaveButtonActionPerformed

    private void chartVerifyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chartVerifyButtonActionPerformed

      JDialog dia = new JDialog(chartDialog, "Dados", true);
      JTable tab = new JTable(dataTable, new String[]{"Ponto", "Data", "Vendas totais", "Arrecadação Total"});

      dia.add(new JScrollPane(tab));
      dia.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
      dia.pack();
      dia.setLocationRelativeTo(null);
      dia.setVisible(true);

}//GEN-LAST:event_chartVerifyButtonActionPerformed

    private void calendarPreviousButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_calendarPreviousButtonActionPerformed
      showCalendar(Calendar.PREVIOUS_MONTH);
}//GEN-LAST:event_calendarPreviousButtonActionPerformed

    private void calendarNextButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_calendarNextButtonActionPerformed
      showCalendar(Calendar.NEXT_MONTH);
}//GEN-LAST:event_calendarNextButtonActionPerformed

    private void calendarYearTextfieldFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_calendarYearTextfieldFocusGained
      calendarYearTextfield.setText("");
}//GEN-LAST:event_calendarYearTextfieldFocusGained

    private void calendarYearTextfieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_calendarYearTextfieldFocusLost
      if (calendarYearTextfield.getText().equals("")) {
        calendarYearTextfield.setText("Selecionar ano");
      }
}//GEN-LAST:event_calendarYearTextfieldFocusLost

    private void calendarTodayButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_calendarTodayButtonActionPerformed
      showCalendar(0);
}//GEN-LAST:event_calendarTodayButtonActionPerformed

    private void calendarGoButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_calendarGoButtonActionPerformed
      int month, year;

      month = calendarMonthComboBox.getSelectedIndex();
      if (month == 0) {
        return;
      }
      month--;

      String ano = calendarYearTextfield.getText();
      if (ano.equals("Selecionar ano") || ano.equals("")) {
        year = 0;
      } else {
        try {
          year = Integer.parseInt(ano);
        } catch (NumberFormatException nfe) {
          year = 0;
        }
        showCalendar(year, month);

      }
    }//GEN-LAST:event_calendarGoButtonActionPerformed

    private void phonesSaveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_phonesSaveButtonActionPerformed
      savePhoneTable();
}//GEN-LAST:event_phonesSaveButtonActionPerformed

    private void settingsServerConnectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_settingsServerConnectButtonActionPerformed
      Communication comtn = new Communication();
      if (!comtn.isConnected()) {
        comtn.connect();
      }
    }//GEN-LAST:event_settingsServerConnectButtonActionPerformed

    private void settingsServerTextFieldFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_settingsServerTextFieldFocusGained
      settingsServerTextField.setText("");
}//GEN-LAST:event_settingsServerTextFieldFocusGained

    private void settingsServerTextFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_settingsServerTextFieldFocusLost
      settingsServerTextField.setText("servidor:porta");
    }//GEN-LAST:event_settingsServerTextFieldFocusLost

    private void settingsServerEditButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_settingsServerEditButtonActionPerformed
      Server.addServer(settingsServerTextField.getText());
      settingsServerCombobox.setModel(new javax.swing.DefaultComboBoxModel(Server.getServers()));
    }//GEN-LAST:event_settingsServerEditButtonActionPerformed

    private void dbSynchButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dbSynchButtonActionPerformed
      DataBase.synchronizeFromServer();
    }//GEN-LAST:event_dbSynchButtonActionPerformed

    private void saleDialogReqButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saleDialogReqButtonActionPerformed
      if(!Communication.isConnected()) return;

      String amount = saleDialogReqField.getText();
      String[] d = Products.getData(currentProdRow);
      int newValue = Integer.parseInt(amount);
      int oldValue = Integer.parseInt(d[5]);
      // escreve o produto com mais estoque local
      d[5] = Integer.toString(oldValue + newValue);
      DataBase.writeData(DataBase.PRODUCTS, d);
      // escreve a requisicao
      Locale locale = Locale.getDefault();
      DateFormat formatter = new SimpleDateFormat("dd/MM/yy HH:mm", locale);
      String s = formatter.format(new Date());

      DataBase.writeData(DataBase.REQUISITIONS, new String[]{d[0], d[1], amount, s});

      // envia requisicao ao server
      Communication.reserva(d[0], amount);

      //atualiza banco de acordo com server
      refreshProdTable();
      saleDialog.setVisible(false);
      saleDialog.dispose();
      showPanel(prodPanel);

}//GEN-LAST:event_saleDialogReqButtonActionPerformed

    private void saleDialogDevButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saleDialogDevButtonActionPerformed
      if(!Communication.isConnected()) return;
      String[] d = Products.getData(currentProdRow);
      Communication.devolucao(d[0], d[5]);
    }//GEN-LAST:event_saleDialogDevButtonActionPerformed

    private void prodDevButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_prodDevButtonActionPerformed
      String[][] data = Products.getData();
      for(String[] row : data) {
        if(Integer.valueOf(row[0]) > 0)
          Communication.devolucao(row[0], row[5]);
      }
    }//GEN-LAST:event_prodDevButtonActionPerformed

  /**
   * @param args the command line arguments
   */
  public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {

      public void run() {
        new mainFrame().setVisible(true);
      }
    });
  }

  /*******************************************************************************************************************
   * trace
   *******************************************************************************************************************/
  private static void trace(Object o) {
    System.out.println(o);
  }
  // Variables declaration - do not modify//GEN-BEGIN:variables
  private javax.swing.JDialog aboutDialog;
  private javax.swing.JLabel aboutDialogLabel;
  private javax.swing.JToggleButton calendarButton;
  private javax.swing.JButton calendarCloseButton;
  private javax.swing.JButton calendarGoButton;
  private javax.swing.JLabel calendarLabel;
  private javax.swing.JLabel calendarMonthAndYearLabel;
  private javax.swing.JComboBox calendarMonthComboBox;
  private javax.swing.JButton calendarNextButton;
  private javax.swing.JPanel calendarPanel;
  private javax.swing.JButton calendarPreviousButton;
  private javax.swing.JScrollPane calendarScrollPane;
  private javax.swing.JTable calendarTable;
  private javax.swing.JButton calendarTodayButton;
  private javax.swing.JTextField calendarYearTextfield;
  private javax.swing.JButton chartCloseButton;
  private javax.swing.JDialog chartDialog;
  private javax.swing.JLabel chartDialogLabel;
  private javax.swing.JLabel chartRequestsLabel;
  private javax.swing.JLabel chartSalesLabel;
  private javax.swing.JButton chartSaveButton;
  private javax.swing.JButton chartVerifyButton;
  private javax.swing.JToggleButton chartsButton;
  private javax.swing.JButton chartsCloseButton;
  private javax.swing.JLabel chartsLabel;
  private javax.swing.JPanel chartsPanel;
  private javax.swing.JPanel chartsRequestsPanel;
  private javax.swing.JPanel chartsSalesPanel;
  private javax.swing.JTabbedPane chartsTabbedPane;
  private javax.swing.JPanel contentPanel;
  private javax.swing.JToggleButton dbButton;
  private javax.swing.JButton dbCloseButton;
  private javax.swing.JLabel dbLabel;
  private javax.swing.JPanel dbPanel;
  private javax.swing.JButton dbSynchButton;
  private javax.swing.JPanel defaultPanel;
  private javax.swing.JToggleButton helpButton;
  private javax.swing.JButton helpCloseButton;
  private javax.swing.JPanel helpPanel;
  private javax.swing.JLabel jLabel2;
  private javax.swing.JLabel jLabel5;
  private javax.swing.JMenu jMenu1;
  private javax.swing.JMenu jMenu10;
  private javax.swing.JMenu jMenu11;
  private javax.swing.JMenu jMenu3;
  private javax.swing.JMenu jMenu4;
  private javax.swing.JMenu jMenu5;
  private javax.swing.JMenu jMenu6;
  private javax.swing.JMenu jMenu7;
  private javax.swing.JMenu jMenu8;
  private javax.swing.JMenu jMenu9;
  private javax.swing.JMenuItem jMenuItem1;
  private javax.swing.JMenuItem jMenuItem10;
  private javax.swing.JMenuItem jMenuItem11;
  private javax.swing.JMenuItem jMenuItem12;
  private javax.swing.JMenuItem jMenuItem13;
  private javax.swing.JMenuItem jMenuItem14;
  private javax.swing.JMenuItem jMenuItem15;
  private javax.swing.JMenuItem jMenuItem16;
  private javax.swing.JMenuItem jMenuItem17;
  private javax.swing.JMenuItem jMenuItem18;
  private javax.swing.JMenuItem jMenuItem19;
  private javax.swing.JMenuItem jMenuItem2;
  private javax.swing.JMenuItem jMenuItem20;
  private javax.swing.JMenuItem jMenuItem21;
  private javax.swing.JMenuItem jMenuItem22;
  private javax.swing.JMenuItem jMenuItem23;
  private javax.swing.JMenuItem jMenuItem3;
  private javax.swing.JMenuItem jMenuItem4;
  private javax.swing.JMenuItem jMenuItem5;
  private javax.swing.JMenuItem jMenuItem6;
  private javax.swing.JMenuItem jMenuItem7;
  private javax.swing.JMenuItem jMenuItem8;
  private javax.swing.JMenuItem jMenuItem9;
  private javax.swing.JScrollPane jScrollPane1;
  private javax.swing.JToolBar.Separator jSeparator1;
  private javax.swing.JTextArea jTextArea1;
  private javax.swing.JButton loginButton;
  private javax.swing.JButton loginCancelButton;
  private javax.swing.JButton loginClearButton;
  private javax.swing.JLabel loginLabel;
  private javax.swing.JButton loginOKButton;
  private javax.swing.JPanel loginPanel;
  private javax.swing.JPasswordField loginPassField;
  private javax.swing.JLabel loginPassLabel;
  private javax.swing.JToolBar loginToolbar;
  private javax.swing.JTextField loginUserField;
  private javax.swing.JLabel loginUserLabel;
  private javax.swing.JPanel mainPanel;
  private javax.swing.JMenuBar menuBar;
  private javax.swing.JToggleButton phoneButton;
  private javax.swing.JButton phonesCloseButton;
  private javax.swing.JLabel phonesLabel;
  private javax.swing.JPanel phonesPanel;
  private javax.swing.JButton phonesRefreshButton;
  private javax.swing.JButton phonesSaveButton;
  private javax.swing.JTable phonesTable;
  private javax.swing.JScrollPane phonesTableScrollPane;
  private javax.swing.JToggleButton prodButton;
  private javax.swing.JButton prodCloseButton;
  private javax.swing.JButton prodCloseButton1;
  private javax.swing.JButton prodDevButton;
  private javax.swing.JLabel prodLabel;
  private javax.swing.JPanel prodPanel;
  private javax.swing.JButton prodRefreshButton;
  private javax.swing.JTable prodTable;
  private javax.swing.JScrollPane prodTableScrollPane;
  private javax.swing.JDialog saleDialog;
  private javax.swing.JLabel saleDialogAmount;
  private javax.swing.JLabel saleDialogAmount1;
  private javax.swing.JTextField saleDialogAmountField;
  private javax.swing.JLabel saleDialogAmountTotal;
  private javax.swing.JButton saleDialogCancelButton;
  private javax.swing.JButton saleDialogDevButton;
  private javax.swing.JLabel saleDialogID;
  private javax.swing.JLabel saleDialogName;
  private javax.swing.JButton saleDialogOKButton;
  private javax.swing.JLabel saleDialogPrice;
  private javax.swing.JButton saleDialogReqButton;
  private javax.swing.JTextField saleDialogReqField;
  private javax.swing.JLabel saleDialogReqTotal;
  private javax.swing.JLabel saleDialogType;
  private javax.swing.JToggleButton salesButton;
  private javax.swing.JButton salesCloseButton;
  private javax.swing.JButton salesCreateChartButton;
  private javax.swing.JLabel salesLabel;
  private javax.swing.JPanel salesPanel;
  private javax.swing.JButton salesRefreshButton;
  private javax.swing.JButton salesSelectAllButton;
  private javax.swing.JTable salesTable;
  private javax.swing.JScrollPane salesTableScrollPane;
  private javax.swing.JToggleButton settingsButton;
  private javax.swing.JButton settingsCloseButton;
  private javax.swing.JPanel settingsConLabel;
  private javax.swing.JLabel settingsLabel;
  private javax.swing.JPanel settingsPanel;
  private javax.swing.JComboBox settingsServerCombobox;
  private javax.swing.JButton settingsServerConnectButton;
  private javax.swing.JButton settingsServerEditButton;
  private javax.swing.JLabel settingsServerLabel;
  private javax.swing.JButton settingsServerListRefreshButton;
  private javax.swing.JTextField settingsServerTextField;
  private javax.swing.JToolBar toolBar;
  private javax.swing.ButtonGroup toolbarbuttonGroup;
  // End of variables declaration//GEN-END:variables
  private javax.swing.JPanel currentPanel;
  private int currentProdRow;
  private String[][] dataTable;
  private BufferedImage chart;
}


